//Server

   import java.io.*;
   import java.util.*;
   import java.net.*;

    public class Server
   {
   	
      public ServerSocket inServer, outServer;
      public LinkedListAd info = new LinkedListAd();
      public String input;
   	
       public static void main(String[] args)
      {
      
         new Server();
      
      }
   
       public Server()
      {
      
         try
         {
            inServer = new ServerSocket(4444);
            outServer = new ServerSocket(4445);
                        
            boolean listening = true;
         
            while(listening)
            {
            
               Socket clientSocket = null;
               inServer.setSoTimeout(100);
               outServer.setSoTimeout(100);
            
               try
               {
                              	
                  clientSocket = inServer.accept();
                  
                  System.out.println("Connected..");
                  
                  BufferedReader in = new BufferedReader( 
                        new InputStreamReader(clientSocket.getInputStream()));
                  
                  String[] data = new String[3];
                  int x = 0;
                  								
                  while((input = in.readLine()) != null)
                  {
                     
                     data[x] = input;
                     
                     x++;
                                          
                  }
                  
                  info.add(data[0], data[1], data[2]);
                  
                  clientSocket.close(); 
                	
                  System.out.println("Done...");
                  System.out.println(info.print());
               	     	        
               }
                   catch(IOException e)
                  { 
                  	             								
                  }
                           	
               try
               {
               
                  new outputServer(outServer.accept(), info).start();
               
               }
                   catch(IOException e)
                  {
                  			
                  }      		            	
            }
         
         }
             catch(IOException e)
            {
            
               System.out.println("ERROR!:" + e);
               System.exit(0);
            
            }
      }
      
   }